import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-11-03
 * Time: 10:21
 * To BE A Better Person-2020-3-2
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    //tomcat会在合适的时机调用doGet方法，通过Get请求触发
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       // super.doGet(req, resp);
        //这个响应只是打印在服务器的控制台上
        System.out.println("helloServlet");
        //这个响应是打印在页面上
        //helloservlet作为响应报文的body
        resp.getWriter().write("hellojava");
    }
}

/**
 * 代码中没有main方法，因为main方法已经在Tomcat中了，只需要将程序部署在Tomcat中即可
 */
